/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fanta.framework.persistence;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author alessandro
 */
@Entity
@Table(name = "giornatelega")
@NamedQueries({
    @NamedQuery(name = "Giornatelega.findAll", query = "SELECT g FROM Giornatelega g"),
    @NamedQuery(name = "Giornatelega.findById", query = "SELECT g FROM Giornatelega g WHERE g.id = :id"),
    @NamedQuery(name = "Giornatelega.findByPuntiteam1", query = "SELECT g FROM Giornatelega g WHERE g.puntiteam1 = :puntiteam1"),
    @NamedQuery(name = "Giornatelega.findByPuntiteam2", query = "SELECT g FROM Giornatelega g WHERE g.puntiteam2 = :puntiteam2"),
    @NamedQuery(name = "Giornatelega.findByDataapertura", query = "SELECT g FROM Giornatelega g WHERE g.dataapertura = :dataapertura"),
    @NamedQuery(name = "Giornatelega.findByDatachiusura", query = "SELECT g FROM Giornatelega g WHERE g.datachiusura = :datachiusura")})
public class Giornatelega implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "puntiteam1")
    private double puntiteam1;
    @Basic(optional = false)
    @Column(name = "puntiteam2")
    private double puntiteam2;
    @Column(name = "dataapertura")
    @Temporal(TemporalType.DATE)
    private Date dataapertura;
    @Column(name = "datachiusura")
    @Temporal(TemporalType.DATE)
    private Date datachiusura;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idlegagiornata")
    private Collection<Formazione> formazioneCollection;
    @JoinColumn(name = "idteam1", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Team idteam1;
    @JoinColumn(name = "idteam2", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Team idteam2;
    @JoinColumn(name = "lega", referencedColumnName = "nome")
    @ManyToOne(optional = false)
    private Lega lega;
    @JoinColumn(name = "data", referencedColumnName = "data")
    @ManyToOne(optional = false)
    private DateGiornate data;
    @JoinColumn(name = "moduloteam1", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Modulo moduloteam1;
    @JoinColumn(name = "moduloteam2", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Modulo moduloteam2;

    public Giornatelega() {
    }

    public Giornatelega(Integer id) {
        this.id = id;
    }

    public Giornatelega(Integer id, double puntiteam1, double puntiteam2) {
        this.id = id;
        this.puntiteam1 = puntiteam1;
        this.puntiteam2 = puntiteam2;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public double getPuntiteam1() {
        return puntiteam1;
    }

    public void setPuntiteam1(double puntiteam1) {
        this.puntiteam1 = puntiteam1;
    }

    public double getPuntiteam2() {
        return puntiteam2;
    }

    public void setPuntiteam2(double puntiteam2) {
        this.puntiteam2 = puntiteam2;
    }

    public Date getDataapertura() {
        return dataapertura;
    }

    public void setDataapertura(Date dataapertura) {
        this.dataapertura = dataapertura;
    }

    public Date getDatachiusura() {
        return datachiusura;
    }

    public void setDatachiusura(Date datachiusura) {
        this.datachiusura = datachiusura;
    }

    public Collection<Formazione> getFormazioneCollection() {
        return formazioneCollection;
    }

    public void setFormazioneCollection(Collection<Formazione> formazioneCollection) {
        this.formazioneCollection = formazioneCollection;
    }

    public Team getIdteam1() {
        return idteam1;
    }

    public void setIdteam1(Team idteam1) {
        this.idteam1 = idteam1;
    }

    public Team getIdteam2() {
        return idteam2;
    }

    public void setIdteam2(Team idteam2) {
        this.idteam2 = idteam2;
    }

    public Lega getLega() {
        return lega;
    }

    public void setLega(Lega lega) {
        this.lega = lega;
    }

    public DateGiornate getData() {
        return data;
    }

    public void setData(DateGiornate data) {
        this.data = data;
    }

    public Modulo getModuloteam1() {
        return moduloteam1;
    }

    public void setModuloteam1(Modulo moduloteam1) {
        this.moduloteam1 = moduloteam1;
    }

    public Modulo getModuloteam2() {
        return moduloteam2;
    }

    public void setModuloteam2(Modulo moduloteam2) {
        this.moduloteam2 = moduloteam2;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Giornatelega)) {
            return false;
        }
        Giornatelega other = (Giornatelega) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fanta.framework.persistence.Giornatelega[id=" + id + "]";
    }

}
